package db

import (
	"database/sql"
	"github.com/xiyoufang/cloud-syncer/internal/http/model"
)

const (
	SQLITE    = "sqlite"
	BatchSize = 10000
)

// File 扫描到的文件基本信息
type File struct {
	Name       string
	Size       int64
	Modified   int64
	LocalPath  string
	RemotePath string
}

// Query 脚本
type Query struct {
	Name string
	Sql  string
}

// Task 需要上传的任务
type Task struct {
	Id         int64
	LocalPath  string
	RemotePath string
}

type Repository interface {
	Migrate() error
	Vacuum() error
	TruncateTempTable() (int64, error)            // 清理临时表数据
	InsertBatchFiles(files []File) (int64, error) // 批量插入文件
	MergeFilesAndInsertHistories() error
	GetPendingHistories(limit int) ([]Task, error)
	UpdateHistorySyncStatus(id int64, status int, message string) (int64, error)
	CommitOrRollback(tx *sql.Tx, err error) error
	GetFilesPaginate(req model.PaginateReq) (model.PageVO, error)
	GetHistoriesPaginate(req model.PaginateReq) (model.PageVO, error)
	GetSyncStats() (model.SyncStatsVO, error)
	GetFileStats() (model.FileStatsVO, error)
	GetLast30dSyncStatistics() (model.Last30dSyncStatisticsVO, error)
}
